/**
 * THIS OBJECT IS MEANT TO BE THE 'SERVER SIDE' OF THE CLIENT
 * IN OTHER WORDS, IT IS SUPPOSED TO RECEIVE INVOCATIONS FROM THE RMI SERVER
 * So it behaves as a REMOTE OBSERVER
 * TO BE COMPLETED BY THE STUDENTS
 */
package RMIClient;

import raceReservationServer.IReservationRaceServer;
import raceReservationServer.RaceRMIDTO;
import util.observer.rmi.RemoteObserver;

import java.rmi.RemoteException;

public class RaceRemoteObserver extends RemoteObserver {
	private static final long serialVersionUID = 1L;

	/**
	 * Creates a new instance of RemoteObserver ADD AS MUCH INFORMATION AS
	 * NEEDED
	 */
	private RaceController controller = null;
	private IReservationRaceServer controllerServ = null;
	
	public RaceRemoteObserver(RaceController controller, IReservationRaceServer server) throws RemoteException
	{
		super();
		this.controller = controller;
		this.controllerServ = server;
		server.addRemoteObserver(this);
	}

	public void stop() throws RemoteException 
	{
		controllerServ.deleteRemoteObserver(this);
	}

	public void update(Object arg) throws java.rmi.RemoteException
	{
		controller.updateRace((RaceRMIDTO) arg);
	}
}
